package com.wn.user.controller;

import com.wn.common.entity.Coordinate;
import com.wn.common.entity.MyRsp;
import com.wn.common.pojo.AreaVillage;
import com.wn.user.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @BelongsProject: shared_parking
 * @BelongsPackage: com.wn.user.controller
 * @Author: 廖刚
 * @CreateTime: 2020-06-18 11:08
 * @Description:
 */
@Api(value = "地区小区模块接口",description = "这是一个关于地区小区的接口文档")
@RestController
public class AreaController {

    private final static Logger logger = LoggerFactory.getLogger(AreaController.class);

    @Autowired
    private AreaService areaService;

    @PostMapping("getVillageByAId")
    public List<AreaVillage> getVillageByAId(String aid){


        return areaService.getVillageByAId(aid);
    }


    @PostMapping("getVillageByAreaName")
    public List<AreaVillage> getVillageByAreaName(String aName){

        return areaService.getVillageByAreaName(aName);
    }


    @ApiOperation("通过名称获取它的坐标")
    @PostMapping("getCoordinateByName")
    public MyRsp getCoordinateByName(@RequestBody AreaVillage areaVillage){
        logger.info("aName:{}",areaVillage.getAName());

        return areaService.getAreaByName(areaVillage);
    }

    //获取用户位置坐标
    @ApiOperation("获取用户位置坐标")
    @PostMapping("getCoordinate")
    public MyRsp getCoordinate(@RequestBody Coordinate coordinate){

        //logger.info("坐标:{}",coordinate);

        return areaService.getCoordinate(coordinate);
    }



    //动态查询地区小区表
    @ApiOperation("动态查询地区小区表")
    @PostMapping("getListByAreaVillage")
    public MyRsp getListByAreaVillage(@RequestBody AreaVillage areaVillage){

        return areaService.getListByAreaVillage(areaVillage);
    }
}
